#include "CStatusbar.h"

CStatusbar::CStatusbar() {
  m_hStatusbar = NULL;
}

void CStatusbar::SetHandle(HWND hStatusbar) {
  m_hStatusbar = hStatusbar;
}

HWND CStatusbar::GetHandle() {
  return m_hStatusbar;
}

//STYLES: SBARS_SIZEGRIP, SBARS_TOOLTIPS
HWND CStatusbar::Create(DWORD dwStyle, LPCTSTR lpszText, HWND hParent,
    UINT nID) {
  m_hStatusbar = ::CreateStatusWindow(WS_VISIBLE | WS_CHILD | dwStyle,
      lpszText, hParent, nID);

  return m_hStatusbar;
}

BOOL CStatusbar::Destroy() {
  return ::DestroyWindow(m_hStatusbar);
}

INT CStatusbar::Simple(BOOL bSimple) {
  return ::SendMessage(m_hStatusbar, SB_SIMPLE, bSimple, 0);
}

INT CStatusbar::IsSimple() {
  return ::SendMessage(m_hStatusbar, SB_ISSIMPLE, 0, 0);
}

INT CStatusbar::GetClientRect(LPRECT rect) {
  return ::GetClientRect(m_hStatusbar, rect);
}

INT CStatusbar::GetBorders(LPINT aBorders) {
  return ::SendMessage(m_hStatusbar, SB_GETBORDERS, 0, (LPARAM)aBorders);
}

INT CStatusbar::SetIcon(INT iPart, HICON hIcon) {
  return ::SendMessage(m_hStatusbar, SB_SETICON, iPart, (LPARAM)hIcon);
}

HICON CStatusbar::GetIcon(INT iPart) {
  return (HICON)::SendMessage(m_hStatusbar, SB_GETICON, iPart, 0);
}

INT CStatusbar::SetParts(INT nParts, LPINT aWidths) {
  return ::SendMessage(m_hStatusbar, SB_SETPARTS, nParts, (LPARAM)aWidths);
}

INT CStatusbar::GetParts(INT nParts, LPINT aRightCoord) {
  return ::SendMessage(m_hStatusbar, SB_GETPARTS, nParts, (LPARAM)aRightCoord);
}

INT CStatusbar::GetRect(INT iPart, LPRECT lprc) {
  return ::SendMessage(m_hStatusbar, SB_GETRECT, iPart, (LPARAM)lprc);
}

//SBT_NOBORDERS, SBT_OWNERDRAW, SBT_POPOUT, SBT_RTLREADING, SBT_NOTABPARSING
INT CStatusbar::SetText(INT iPart, INT uType, LPSTR szText) {
  return ::SendMessage(m_hStatusbar, SB_SETTEXT, iPart | uType, (LPARAM)szText);
}

INT CStatusbar::GetText(INT iPart, LPSTR szText) {
  return ::SendMessage(m_hStatusbar, SB_GETTEXT, iPart, (LPARAM)szText);
}

INT CStatusbar::GetTextLength(INT iPart) {
  return ::SendMessage(m_hStatusbar, SB_GETTEXTLENGTH, iPart, 0);
}

INT CStatusbar::SetTipText(INT iPart, LPCTSTR lpszTooltip) {
  return ::SendMessage(m_hStatusbar, SB_SETTIPTEXT, iPart, (LPARAM)lpszTooltip);
}

INT CStatusbar::GetTipText(INT iPart, INT nSize, LPCTSTR lpszTooltip) {
  return ::SendMessage(m_hStatusbar, SB_GETTIPTEXT, MAKEWPARAM(iPart, nSize),
      (LPARAM)lpszTooltip);
}

INT CStatusbar::SetUnicodeFormat(BOOL bUnicode) {
  return ::SendMessage(m_hStatusbar, SB_SETUNICODEFORMAT, bUnicode, 0);
}

INT CStatusbar::GetUnicodeFormat() {
  return ::SendMessage(m_hStatusbar, SB_GETUNICODEFORMAT, 0, 0);
}

//CLR_DEFAULT
INT CStatusbar::SetBkColor(COLORREF clrBk) {
  return ::SendMessage(m_hStatusbar, SB_SETBKCOLOR, 0, (LPARAM)clrBk);
}

INT CStatusbar::SetMinHeight(INT minHeight) {
  return ::SendMessage(m_hStatusbar, SB_SETMINHEIGHT, minHeight, 0);
}

LRESULT CStatusbar::OnSize() {
  return ::SendMessage(m_hStatusbar, WM_SIZE, 0, 0);
}

